import { defineStore } from "pinia";
import { ref } from "vue";

export const useUserStore = defineStore('user',
  ()=>
 {
  const token = ref('')
  const username = ref('')
  const pic = ref('')
  const nickname = ref('')
  const email = ref('')
  const setToken = (newToken) => {
    token.value = newToken
  }

  const setUserName = (newToken) => {
    username.value = newToken
  }
  const removeToken = () => {
    token.value = ''
  }

  const removeUserName = () => {
    username.value = ''
  }

  const setPic = (newToken) => {
    pic.value = newToken
  }

  const setNickname = (newToken) => {
   nickname.value = newToken
  }

  const setEmail = (newToken) => {
   email.value = newToken
  }

  const removeNickname = () => {
    nickname.value = ''
  }

  const removeEmail = () => {
    email.value = ''
  }

  const removePic = () => {
    pic.value = ''
  }
  return {
    token, 
    username,
    pic,
    nickname,
    email,
    setToken,
    setUserName,
    setPic,
    setEmail,
    setNickname,
    removeToken,
    removePic,
    removeEmail,
    removeNickname
  }
},{
  persist:true
})
  
